//
//  RouterDetailViewController.swift
//  TestIos
//
//  Created by liyadong on 2025/11/11.
//  Copyright © 2025 Liyadong. All rights reserved.
//

import UIKit
import SnapKit

@objc(RouterDetailViewController)
class RouterDetailViewController: UIViewController {
    
    var userId: String?
    var userName: String?
    var extraInfo: [String: Any]?
    
    private let infoLabel = UILabel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .white
        title = "路由详情页"
        
        setupUI()
        displayInfo()
    }
    
    private func setupUI() {
        infoLabel.numberOfLines = 0
        infoLabel.textAlignment = .center
        infoLabel.font = .systemFont(ofSize: 16)
        infoLabel.textColor = .darkGray
        view.addSubview(infoLabel)
        
        infoLabel.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.leading.trailing.equalToSuperview().inset(20)
        }
    }
    
    private func displayInfo() {
        var infoText = "路由参数信息：\n\n"
        
        if let userId = userId {
            infoText += "用户ID: \(userId)\n"
        }
        
        if let userName = userName {
            infoText += "用户名: \(userName)\n"
        }
        
        if let extraInfo = extraInfo {
            infoText += "\n额外信息:\n"
            for (key, value) in extraInfo {
                infoText += "\(key): \(value)\n"
            }
        }
        
        infoLabel.text = infoText
    }
}

